package com.haust.trade.controller;

import com.haust.commons.pojo.HaustResult;
import com.haust.pojo.TbOrder;
import com.haust.pojo.TbOrderShipping;
import com.haust.pojo.TbUser;
import com.haust.trade.service.TradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@CrossOrigin
public class TradeController {
    @Autowired
    private TradeService tradeService;

    @PostMapping("/order/insertOrder")
    public HaustResult goSettlement(TbOrder order,
                                      TbOrderShipping orderShipping,
                                      String orderItem,
                                      @RequestHeader("Token") String token
            , HttpSession session) {
        System.out.println(order);
        System.out.println(orderShipping);
        System.out.println(orderItem);
        return tradeService.goSettlement(orderItem, orderShipping, order, (TbUser) session.getAttribute("loginUser"),token);
    }
}
